package com.jsgt.greekfire.ui.market.fragement

import android.os.Bundle
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.fhx.core.base.BaseFragment
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.CurrencyDescribe
import com.jsgt.greekfire.factory.KLineViewModelFactory
import com.jsgt.greekfire.factory.MarketViewModelFactory
import com.jsgt.greekfire.viewmodel.KLineViewModel
import com.jsgt.greekfire.viewmodel.MarketViewModel
import kotlinx.android.synthetic.main.fragment_introduce.*

private const val ARG_PARAM1 = "param1"

class SynopsisFragment : BaseFragment() {
    private var symbol: String? = null
    private var currencyDescribe: CurrencyDescribe? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
            symbol = it.getString(ARG_PARAM1)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.fragment_introduce
    }

    companion object {
        @JvmStatic
        fun newInstance(param1: String) =
            SynopsisFragment().apply {
                arguments = Bundle().apply {
                    putString(ARG_PARAM1, param1)
                }
            }
    }

    override fun main() {
        refreshView()
    }

    fun setData(currencyDescribe: CurrencyDescribe) {
        this.currencyDescribe = currencyDescribe
        refreshView()
    }

    private fun refreshView() {
        txvName.text = currencyDescribe?.name.toString()
        txvCreateTime.text = currencyDescribe?.releaseTime.toString()
        txvTotal.text = currencyDescribe?.distributionAmount.toString()
        txvCirculation.text = currencyDescribe?.circulationAmount.toString()
        txvPrice.text = currencyDescribe?.crowdfunding.toString()
        txvWhitePaper.text = currencyDescribe?.whitePaper.toString()
        txvOfficialWebsite.text = currencyDescribe?.website.toString()
        txvBlockQuery.text = currencyDescribe?.blockUrl.toString()
        txvCoinIntroduce.text = currencyDescribe?.introduction.toString()
    }
}